#include "mainwindow.h"
#include <QDebug>
#include "ui_mainwindow.h"
#include "RenderView.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    RenderView *rv = new RenderView();
    ui->mainLayout->addWidget(rv, 0, 0, 1, 1);
    rv->startRendering();
    ui->statusBar->showMessage("Calculating fps...");
    connect(rv, SIGNAL(fps(unsigned int)), this, SLOT(OnFPS(unsigned int)));
    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(OnOpenShader()));
    connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(OnExitProgram()));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::OnOpenShader()
{
  qDebug() << "Shader Open";
}

void MainWindow::OnExitProgram()
{
  qDebug() << "Program Closed";
}

void MainWindow::OnFPS(unsigned int fps)
{
  ui->statusBar->showMessage(QString("%1 fps").arg(fps));
}
